﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="eesmargidType_v4", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(EesmargidTypeV4))]
    public class EesmargidTypeV4Serializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IEesmargidTypeV4 clazz;
        
        public EesmargidTypeV4Serializer(IEesmargidTypeV4 clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.Nimetus!=null) {
                Writer.WriteStartElement("nimetus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Nimetus))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Tegevus!=null) {
                Writer.WriteStartElement("tegevus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Tegevus))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="nimetus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>eesmargidType_v4>nimetus");
                }
                clazz.Nimetus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("nimetus")).Value;
            }
            if (Reader.LocalName=="tegevus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>eesmargidType_v4>tegevus");
                }
                clazz.Tegevus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("tegevus")).Value;
            }
        }
    }
}
